/**
  * @file     	menu.c
  * @author   	YangHaifeng
  * @email   	2995339193@qq.com
  * @version	V0.0
  * @license  	GNU General Public License (GPL)  
  * @detail		please follow the license!!!
  * @attention
  *  this file is aim to do something with menu									
  *   																	
  * @htmlonly 
  * <span style="font-weight: bold">History</span> 
  * @endhtmlonly 
  * Version|Auther|Describe
  * ------|----|-------- 
  * V0.0|YangHaifeng|Create File
  * <h2><center>&copy;COPYRIGHT YangHaifeng All Rights Reserved.</center></h2>
  */ 
  
#include "menu.h"

//记录选项的变量
uint8_t option = 0;


//菜单表声明
menu_table_t table[];




/**
 * @brief 主菜单
 * @param None
 * @retval None
 * @author YangHaifeng
 */
void main_menu(void)
{
	static uint8_t index = 0;
	
	while(1)
	{
		key_scanf();
		//下翻按键按下
		if(key_value == 1)
		{
			index = table[index].down;
			key_value = 0;
		}
		//确认按键按下
		if(key_value == 2)
		{
			option = table[index].current;
			key_value = 0;
			break;
		}
		table[index].operation();
	}
	OLED_Clear();
}



/**
 * @brief 第1题
 * @param None
 * @retval None
 * @author YangHaifeng
 */
void gui_00d(void)
{
	OLED_ShowString(1,4,"option 1",1);
	OLED_ShowString(2,4,"option 2",0);
	OLED_ShowString(3,4,"option 3",0);
	OLED_ShowString(4,4,"option 4",0);
}



/**
 * @brief 第2题
 * @param None
 * @retval None
 * @author YangHaifeng
 */
void gui_10d(void)
{
	OLED_ShowString(1,4,"option 1",0);
	OLED_ShowString(2,4,"option 2",1);
	OLED_ShowString(3,4,"option 3",0);
	OLED_ShowString(4,4,"option 4",0);	
}


/**
 * @brief 第3题
 * @param None
 * @retval None
 * @author YangHaifeng
 */
void gui_20d(void)
{
	OLED_ShowString(1,4,"option 1",0);
	OLED_ShowString(2,4,"option 2",0);
	OLED_ShowString(3,4,"option 3",1);
	OLED_ShowString(4,4,"option 4",0);
}


/**
 * @brief 第4题
 * @param None
 * @retval None
 * @author YangHaifeng
 */
void gui_30d(void)
{
	OLED_ShowString(1,4,"option 1",0);
	OLED_ShowString(2,4,"option 2",0);
	OLED_ShowString(3,4,"option 3",0);
	OLED_ShowString(4,4,"option 4",1);
}


/**
 * @brief 菜单变量
 */
menu_table_t table[]=
{
	//第一层
	{0,1,gui_00d},
	{1,2,gui_10d},
	{2,3,gui_20d},
	{3,0,gui_30d}
};



